#include <iostream>
#include <algorithm>

using namespace std;

const int N = 1e5 + 10;

typedef long long LL;

int n, m;
LL a[N];

int find(LL b)
{
	int left = 1, right = m;
	while(left < right)
	{
		int mid = left + (right - left) / 2;
		if(a[mid] < b) left = mid + 1;
		else right = mid;
	}
	return left;
}

int main()
{
	cin >> m >> n;
	for(int i = 1; i <= m; i++) cin >> a[i];
	sort(a + 1, a + 1 + m);

	//加上左右护法
	a[0] = -1e7 + 10;

	LL ret = 0;
	for(int i = 1; i <= n; i++)
	{
		//思路：
		//找出大于等于b的最小值的位置
		//min(abs(b - *t), abs(b - *(t-1)))
		//注意越界的情况
		LL b; cin >> b;
		int pos = find(b);
		ret += min(abs(a[pos] - b), abs(a[pos - 1] - b));
	}
	cout << ret << endl;

	return 0;
}

